// TraitsInfo.h: interface for the TraitsInfo class.
// 
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4786)     //Disable warning messages

#if !defined(AFX_TRAITSINFO_H__0A4CE01D_B607_4C23_9B94_D7C6A5761C68__INCLUDED_)
#define AFX_TRAITSINFO_H__0A4CE01D_B607_4C23_9B94_D7C6A5761C68__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "amf3_types.h"

using namespace std;

namespace Amf {
	using namespace std;
	
	class AMF_CLASS_EXPORT TraitsInfo  
	{
	public:
		~TraitsInfo()
		{
			properties.clear();
		};

		TraitsInfo(const wchar_t* className, bool dynamic = false, bool externalizable = false)
		{
			if (className == NULL)
				className = L"";

			this->className = className;
			this->dynamic = dynamic;
			this->externalizable = externalizable;
		}
		
		TraitsInfo(const wchar_t* className, vector<wstring>& properties, bool dynamic = false, bool externalizable = false)
		{
			if (className == NULL)
				className = L"";
			
			this->className = className;
			
			this->properties.swap(properties);
			this->dynamic = dynamic;
			this->externalizable = externalizable;
		}

		bool isDynamic()
		{
			return this->dynamic;
		}
		
		bool isExternalizable()
		{
			return this->externalizable;
		}
		
		int length()
		{
			return this->properties.size();
		}
		
		const wchar_t* getClassName()
		{
			return this->className.c_str();
		}
		
		void addProperty(wstring name)
		{
			this->properties.push_back(name);
		}
		
		void addAllProperties(vector<wstring>& props)
		{
			for(int i = 0; i < props.size(); i ++)
			{
				this->properties.push_back(props[i]);
			}
		}
		
		const wchar_t* getProperty(int i)
		{
			if(i >= 0 && i < this->properties.size())
				return this->properties[i].c_str();
			else
				return NULL;
		}
		
		vector<wstring>& getProperties()
		{
			return this->properties;
		}

		bool equals(TraitsInfo& obj)
		{
			return false;
		}
		
		/**
		* Instances of types with the same classname and number of properties may
		* return the same hash code, however, an equality test will fully
		* test whether they match exactly on individual property names.
		*/
		int hashCode()
		{
			int c = className.length();
			c = dynamic ? c << 2 : c << 1;
			c = c | (properties.size() << 24);
			return c;
		}

//	private:

		wstring	className;
		bool	dynamic;
		bool	externalizable;
		vector<wstring> properties;
		
	};

}// namespace Amf

#endif // !defined(AFX_TRAITSINFO_H__0A4CE01D_B607_4C23_9B94_D7C6A5761C68__INCLUDED_)
